package cn.com.guage.guc.juc;

import java.util.concurrent.CountDownLatch;

public class MyCountDownLatchTest {

	public static void main(String[] args) {
		CountDownLatch countDownLatch = new CountDownLatch(10);
		
		for(int i=0;i<10;i++) {
			new Thread(new Runnable() {
				@Override
				public void run() {
					System.out.println(Thread.currentThread().getName() +"同学");
					System.out.println("起床");
					System.out.println("洗脸");
					System.out.println("刷牙");
					System.out.println("到学校");
					countDownLatch.countDown();
				}
			},"t"+i).start();; 
		}
		
		new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					countDownLatch.await();

					System.out.println("老师开始上课");
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		},"").start();; 

	}

}
